package com.kgc.book.bookmanagerweb.controller;

import com.kgc.book.bean.Bookmanage;
import com.kgc.book.service.BookService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BookController {

    @Reference
    BookService bookService;
    @RequestMapping("/seleBook")
    public List<Bookmanage> seleBook(){
        return bookService.getAll();
    }

    @RequestMapping("/deleBook")
    public String deleBook(Integer id){
        Integer integer = bookService.deleBook(id);
        if(integer>0){
            return "SUCCESS";
        }else{
            return "FAIL";
        }
    }


    @RequestMapping("/addBook")
    public String addBook(@RequestBody Bookmanage bookmanage){
        Integer integer = bookService.addBook(bookmanage);
        if(integer>0){
            return "SUCCESS";
        }else{
            return "FAIL";
        }
    }
}
